﻿
(function () {
    function _standalone(document, navigator, standalone) {
        var isStandalone = (standalone in navigator) && navigator[standalone];
        if (!isStandalone) return;
        var links = document.getElementsByTagName('a');
        for (var i = 0; i < links.length; i++) {
            links[i].addEventListener('click', function (event) {
                var link = this;
                var href = link.getAttribute('href');
                if (href.indexOf('#') == 0 || href.indexOf(':') != -1) return;
                event.preventDefault();
                window.location = href;
            });
        }
    };
    window.Standalone = function () {
        _standalone( document, window.navigator, 'standalone' );
    };
    Standalone();
})();